﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;


namespace IHISCETeim.Web.MachineSys.UserModel
{
    public partial class UAgentMacStockEdit : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.修改 };
            }
        }
        protected override string DWZRef
        {
            get { return "UAgentMacStockList"; }
        }

        protected int UASID {
            get
            {
                return GetRequestValue<int>("UASID", 0);
            }
        }

        private UAgentMacStockInfo _obj = null;
        protected UAgentMacStockInfo obj
        {
            get
            {
                if (_obj == null)
                    _obj = UAgentMacStockController.GetById(UASID);
                return _obj;
            }
        }

        #region

        protected string GetShowDate(object v)
        {
            if (v is DBNull)
                return "";
            else
            {
               return Convert.ToDateTime(v).ToString("yyyy-MM-dd");
            }
        }
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "edit")
            {
                addmenu();
                
            }
        }

        protected void addmenu()
        {
            UAgentMacStockInfo obj2 = Request.SerializableObject<UAgentMacStockInfo>();

            obj2.AgentName = GetRequestValue<string>("dwz.orgLookup.AgentName", "");
            this.AddLog(Permission.修改, obj,obj2);
            if (UAgentMacStockController.Update(obj2))
                SuccessJson("成功修改样机", "");
            else
                ErrorJson("修改样机失败", "");
        }
    }
}